﻿using System;
using System.Reflection;

namespace Alex.Library.Web.Ajax
{
    /// <summary>
    /// 类型工厂
    /// </summary>
    public sealed class TypeFactory
    {
        /// <summary>
        /// 根据类型名称获取类型
        /// </summary>
        /// <param name="typeName">类型名称</param>
        /// <returns>类型</returns>
        public static Type CreateTypeByName(string typeName)
        {
            Type type = null;
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                type = assembly.GetType(typeName);
                if (type != null)
                {
                    break;
                }
            }
            return type;
        }
    }
}
